package com.engr.business.service.impl;

import com.alibaba.fastjson.JSON;
import com.engr.business.dto.ParamDto;
import com.engr.business.service.JobService;
import com.engr.business.util.HttpClientUtils;
import com.engr.business.util.ResultVoUtils;
import com.engr.business.util.SignUtils;
import com.engr.business.vo.ResultVO;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * @program: business
 * @desc:
 * @author: lyx
 * @date: 2019-01-04 17:13
 **/
@Service
public class JobServiceImpl implements JobService {

    @Override
    public String executeJob() {

        Map<String, Object> params = new HashMap<>();
        String timeStamp = SignUtils.getTimeStamp();
        params.put("timestamp", timeStamp);
        params.put("params", SignUtils.getParam());
        params.put("sign", SignUtils.getSign("pamtest",timeStamp));

        String jsonStr = JSON.toJSONString(params);
        byte[] bytes = HttpClientUtils.httpPost("http://180.167.182.91:8801/datahub/cmd/9001?appid=test&ACCESS_TOKEN=UN4ytB9PJ1XsBLRH2593828048a6a38aebe9669fdd85b028", jsonStr);
        String result = new String(bytes);
        System.out.println(result);

        return result;
    }
}
